--TEST--
bool MySQLndUhConnection::setClientOption(resource $connection, int $option, string $value)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
	require_once('config.inc');

	class proxy extends MySQLndUhConnection {
		public function setClientOption($res, $option, $value) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			var_dump($ret = parent::setClientOption($res, $option, $value));
			var_dump(client_option_to_string($option));
			return $ret;
		}
	}

	class proxy2 extends MySQLndUhConnection {
		public function setClientOption($res, $option, $value) {
			var_dump(func_get_args());
			return true;
		}
	}

	class proxy3 extends MySQLndUhConnection {
		public function setClientOption($res, $option, $value) {
			var_dump(func_get_args());
			return $option;
		}
	}

	class proxy4 extends MySQLndUhConnection {
		public function setClientOption($res, $option, $value) {
			var_dump(func_get_args());
		}
	}

	function client_option_to_string($option) {
		static $mapping = array(
			MYSQLND_UH_MYSQLND_OPTION_OPT_CONNECT_TIMEOUT => "MYSQLND_UH_MYSQLND_OPTION_OPT_CONNECT_TIMEOUT",
			MYSQLND_UH_MYSQLND_OPTION_OPT_COMPRESS => "MYSQLND_UH_MYSQLND_OPTION_OPT_COMPRESS",
			MYSQLND_UH_MYSQLND_OPTION_OPT_NAMED_PIPE => "MYSQLND_UH_MYSQLND_OPTION_OPT_NAMED_PIPE",
			MYSQLND_UH_MYSQLND_OPTION_INIT_COMMAND => "MYSQLND_UH_MYSQLND_OPTION_INIT_COMMAND",
			MYSQLND_UH_MYSQLND_READ_DEFAULT_FILE => "MYSQLND_UH_MYSQLND_READ_DEFAULT_FILE",
			MYSQLND_UH_MYSQLND_READ_DEFAULT_GROUP => "MYSQLND_UH_MYSQLND_READ_DEFAULT_GROUP",
			MYSQLND_UH_MYSQLND_SET_CHARSET_DIR => "MYSQLND_UH_MYSQLND_SET_CHARSET_DIR",
			MYSQLND_UH_MYSQLND_SET_CHARSET_NAME => "MYSQLND_UH_MYSQLND_SET_CHARSET_NAME",
			MYSQLND_UH_MYSQLND_OPT_LOCAL_INFILE => "MYSQLND_UH_MYSQLND_OPT_LOCAL_INFILE",
			MYSQLND_UH_MYSQLND_OPT_PROTOCOL => "MYSQLND_UH_MYSQLND_OPT_PROTOCOL",
			MYSQLND_UH_MYSQLND_SHARED_MEMORY_BASE_NAME => "MYSQLND_UH_MYSQLND_SHARED_MEMORY_BASE_NAME",
			MYSQLND_UH_MYSQLND_OPT_READ_TIMEOUT => "MYSQLND_UH_MYSQLND_OPT_READ_TIMEOUT",
			MYSQLND_UH_MYSQLND_OPT_WRITE_TIMEOUT => "MYSQLND_UH_MYSQLND_OPT_WRITE_TIMEOUT",
			MYSQLND_UH_MYSQLND_OPT_USE_RESULT => "MYSQLND_UH_MYSQLND_OPT_USE_RESULT",
			MYSQLND_UH_MYSQLND_OPT_USE_REMOTE_CONNECTION => "MYSQLND_UH_MYSQLND_OPT_USE_REMOTE_CONNECTION",
			MYSQLND_UH_MYSQLND_OPT_USE_EMBEDDED_CONNECTION => "MYSQLND_UH_MYSQLND_OPT_USE_EMBEDDED_CONNECTION",
			MYSQLND_UH_MYSQLND_OPT_GUESS_CONNECTION => "MYSQLND_UH_MYSQLND_OPT_GUESS_CONNECTION",
			MYSQLND_UH_MYSQLND_SET_CLIENT_IP => "MYSQLND_UH_MYSQLND_SET_CLIENT_IP",
			MYSQLND_UH_MYSQLND_SECURE_AUTH => "MYSQLND_UH_MYSQLND_SECURE_AUTH",
			MYSQLND_UH_MYSQLND_REPORT_DATA_TRUNCATION => "MYSQLND_UH_MYSQLND_REPORT_DATA_TRUNCATION",
			MYSQLND_UH_MYSQLND_OPT_RECONNECT => "MYSQLND_UH_MYSQLND_OPT_RECONNECT",
			MYSQLND_UH_MYSQLND_OPT_SSL_VERIFY_SERVER_CERT => "MYSQLND_UH_MYSQLND_OPT_SSL_VERIFY_SERVER_CERT",
			MYSQLND_UH_MYSQLND_OPT_NET_CMD_BUFFER_SIZE => "MYSQLND_UH_MYSQLND_OPT_NET_CMD_BUFFER_SIZE",
			MYSQLND_UH_MYSQLND_OPT_NET_READ_BUFFER_SIZE => "MYSQLND_UH_MYSQLND_OPT_NET_READ_BUFFER_SIZE",
			MYSQLND_UH_MYSQLND_OPT_SSL_KEY => "MYSQLND_UH_MYSQLND_OPT_SSL_KEY",
			MYSQLND_UH_MYSQLND_OPT_SSL_CERT => "MYSQLND_UH_MYSQLND_OPT_SSL_CERT",
			MYSQLND_UH_MYSQLND_OPT_SSL_CA => "MYSQLND_UH_MYSQLND_OPT_SSL_CA",
			MYSQLND_UH_MYSQLND_OPT_SSL_CAPATH => "MYSQLND_UH_MYSQLND_OPT_SSL_CAPATH",
			MYSQLND_UH_MYSQLND_OPT_SSL_CIPHER => "MYSQLND_UH_MYSQLND_OPT_SSL_CIPHER",
			MYSQLND_UH_MYSQLND_OPT_SSL_PASSPHRASE => "MYSQLND_UH_MYSQLND_OPT_SSL_PASSPHRASE"
		);
		return (isset($mapping[$option])) ? $mapping[$option] : 'unknown';
	}


	$conn = mysqlnd_uh_test\connect::mysqli(MYSQLND_UH_TEST_MYSQL_HOST, MYSQLND_UH_TEST_MYSQL_PORT,
		MYSQLND_UH_TEST_MYSQL_USER, MYSQLND_UH_TEST_MYSQL_PASSWD,
		MYSQLND_UH_TEST_MYSQL_DB, MYSQLND_UH_TEST_MYSQL_SOCKET, false, MYSQLI_CLIENT_FOUND_ROWS);
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy());
	$conn = mysqlnd_uh_test\connect::mysqli(MYSQLND_UH_TEST_MYSQL_HOST, MYSQLND_UH_TEST_MYSQL_PORT,
		MYSQLND_UH_TEST_MYSQL_USER, MYSQLND_UH_TEST_MYSQL_PASSWD,
		MYSQLND_UH_TEST_MYSQL_DB, MYSQLND_UH_TEST_MYSQL_SOCKET, false, MYSQLI_CLIENT_FOUND_ROWS, array(MYSQLI_OPT_CONNECT_TIMEOUT => 10));
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy2());
	$conn = mysqlnd_uh_test\connect::mysqli(MYSQLND_UH_TEST_MYSQL_HOST, MYSQLND_UH_TEST_MYSQL_PORT,
		MYSQLND_UH_TEST_MYSQL_USER, MYSQLND_UH_TEST_MYSQL_PASSWD,
		MYSQLND_UH_TEST_MYSQL_DB, MYSQLND_UH_TEST_MYSQL_SOCKET, false, MYSQLI_CLIENT_FOUND_ROWS, array(MYSQLI_OPT_CONNECT_TIMEOUT => 12));
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy3());
	$conn = mysqlnd_uh_test\connect::mysqli(MYSQLND_UH_TEST_MYSQL_HOST, MYSQLND_UH_TEST_MYSQL_PORT,
		MYSQLND_UH_TEST_MYSQL_USER, MYSQLND_UH_TEST_MYSQL_PASSWD,
		MYSQLND_UH_TEST_MYSQL_DB, MYSQLND_UH_TEST_MYSQL_SOCKET, false, MYSQLI_CLIENT_FOUND_ROWS, array(MYSQLI_OPT_CONNECT_TIMEOUT => 13));
		mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy4());
	$conn = mysqlnd_uh_test\connect::mysqli(MYSQLND_UH_TEST_MYSQL_HOST, MYSQLND_UH_TEST_MYSQL_PORT,
		MYSQLND_UH_TEST_MYSQL_USER, MYSQLND_UH_TEST_MYSQL_PASSWD,
		MYSQLND_UH_TEST_MYSQL_DB, MYSQLND_UH_TEST_MYSQL_SOCKET, false, MYSQLI_CLIENT_FOUND_ROWS, array(MYSQLI_OPT_CONNECT_TIMEOUT => 14));
	mysqlnd_uh_test\query_test::mysqli($conn);

	print "done!";
?>
--EXPECTF--
proxy::setClientOption(array (
  0 => NULL,
  1 => 0,
  2 => 10,
))
bool(true)
string(45) "MYSQLND_UH_MYSQLND_OPTION_OPT_CONNECT_TIMEOUT"
proxy::setClientOption(array (
  0 => NULL,
  1 => 8,
  2 => 1,
))
bool(true)
string(35) "MYSQLND_UH_MYSQLND_OPT_LOCAL_INFILE"
array(3) {
  [0]=>
  resource(%d) of type (MySQLnd Connection)
  [1]=>
  int(0)
  [2]=>
  int(12)
}
array(3) {
  [0]=>
  resource(%d) of type (MySQLnd Connection)
  [1]=>
  int(8)
  [2]=>
  int(1)
}
array(3) {
  [0]=>
  resource(%d) of type (MySQLnd Connection)
  [1]=>
  int(0)
  [2]=>
  int(13)
}

Warning: mysqli::options(): (MySQLnd User Handler) The method MySQLndUhConnection::setClientOption() did not return a boolean value as it should in %s on line %d
array(3) {
  [0]=>
  resource(%d) of type (MySQLnd Connection)
  [1]=>
  int(8)
  [2]=>
  int(1)
}

Warning: mysqli_real_connect(): (MySQLnd User Handler) The method MySQLndUhConnection::setClientOption() did not return a boolean value as it should in %s on line %d
array(3) {
  [0]=>
  resource(%d) of type (MySQLnd Connection)
  [1]=>
  int(0)
  [2]=>
  int(14)
}

Warning: mysqli::options(): (MySQLnd User Handler) The method MySQLndUhConnection::setClientOption() did not return a boolean value as it should in %s on line %d
array(3) {
  [0]=>
  resource(%d) of type (MySQLnd Connection)
  [1]=>
  int(8)
  [2]=>
  int(1)
}

Warning: mysqli_real_connect(): (MySQLnd User Handler) The method MySQLndUhConnection::setClientOption() did not return a boolean value as it should in %s on line %d
done!